<template>
	<view>
		<!-- <uni-nav-bar title="登陆"></uni-nav-bar> -->
		<text class="title">注册</text>
		<view >
			<image src="../../static/login/bg.png" mode="" class="bg"></image>
			<image src="../../static/login/icon.png" mode="" class="icon"></image>
		</view>
		<view id="login">
			<view class="login-main">
				<view class="user enter">
					<image src="../../static/login/user.png" mode="" class="user-icon"></image>
					<input  value="" placeholder="请输入手机号" class="input" placeholder-style="color:#e6e6e6;"  v-model="userInfo.username"/>
				</view>
				<view class="pass enter">
					<image src="../../static/login/password.png" mode="" class="user-icon"></image>
					<input :type="tempPass?'text':'password'" value="" placeholder="请输入密码" class="input" placeholder-style="color: #e6e6e6;" v-model="userInfo.password"/>
					<view class="user-pass">
						<image src="../../static/login/pass2.png"  class="pic" @tap="switchPass" ></image>
					</view>
				</view>
				<view class="pass enter">
					<image src="../../static/login/password.png" mode="" class="user-icon"></image>
					<input type="text" value="" placeholder="请再次输入密码" class="input" placeholder-style="color: #e6e6e6;" />
				</view>
				<view class="code enter">
					<image src="../../static/login/passSecend.png" mode="" class="user-icon"></image>
					<input type="text" value="" placeholder="请输入验证码" class="input" placeholder-style="color: #e6e6e6;" 
					v-model="userInfo.verificationCode"
					/>
					<button size="mini" @click="getCode">获取验证码</button>
				</view>
				<view class="text">
					<text>已有账号?</text>
					<navigator url="/pages/login/login" ><text @click="Login" class="bluetext">立即登录</text></navigator>					
				</view>
				<view class="agreement">
					<label>
						<checkbox value=""  />
						<text>我同意签署</text>
						 <text class="bluetext">《用户协议》</text>
						 <text>和</text>
						 <text class="bluetext">《隐私政策》</text>
					</label>			
				</view>
				<button type="default" id="btn-login" @tap="register(userInfo)">注册</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loginStyle:[
					{id:1,imgSrc:'../../static/login/qq.png'},
					{id:2,imgSrc:'../../static/login/wx.png'},
					{id:3,imgSrc:'../../static/login/zfb.png'},
					{id:4,imgSrc:'../../static/login/phone.png'}
				],
				userInfo:{
					username: "13808195362",
					password: "",
					verificationCode:''
				},
				tempPass:false
			}
		},
		methods: {
			// 注册
			async register(userInfo){
				const res=await this.$http.users.register(userInfo)
				if(res.code==604){
					uni.showToast({
					    title: res.msg,
					    duration: 1000,
						icon:'error'
					});
				}
			},
			// 密码显隐
			switchPass(){
				this.tempPass=!this.tempPass
			},
			// 点击获取短信getCode
			 async getCode(){
				const phoneNum=this.userInfo.username
				if(phoneNum){
					const res=await this.$http.users.getdxCode({phoneNum});
				}else{
					console.log('请输入手机号');
				}
			}
		}
	}
</script>

<style lang="scss" scoped>  
.title{
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	top: 60rpx;
	font-size: 40rpx;
	color: white;
	font-weight: bold;
}
.bg{
	width: 100%;
	height: 400rpx;
}
.icon{
	width: 168rpx;
	height: 168rpx;
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	top: 320rpx;
	
}
.user-pass{
	// width: 60rpx;
	// height: 36rpx;
	margin-left: 180rpx;
	.pic{
		width: 50rpx;
		height: 36rpx;
	}
	// margin-left: 180rpx;
}
#login{
	margin-top: 80rpx;
	padding:24rpx;
	.login-main{
		padding-left: 30rpx;
		padding-right: 30rpx;
		height: 900rpx;
		padding-top: 60rpx;
		// border: 1px solid black;
		border-radius: 20rpx;
		box-shadow: 0px 0px 5px #e6e6e6;
		.text{
			margin: 0 auto;
			margin-top: 62rpx;
			margin-bottom: 60rpx;
			width: 245rpx;
			font-size: 28rpx;
			display: flex;
			justify-content: space-between;
			text:nth-child(1){
				color: #868686;
			}
			text:nth-child(2){
				color: #3476fe;
			}
		}
	}
	.enter{
		display: flex;
		align-items: center;
		height: 86rpx;
		border-bottom: 1rpx solid #e6e6e6;
		.user-icon{
			width: 30rpx;
			height: 36rpx;
		}
		.input{
			margin-left: 30rpx;
			// width: 100%;
		}
	}
	.pass{
		margin-top: 20rpx;
	}
	#btn-login{
		color: white;
		font-family:bold ;
		border: none;
		font-size: 28rpx;
		border-radius: 52rpx;
		padding: 10rpx;
		// background-color: #3476fe;
		background-image: linear-gradient(to bottom ,#4fa4f3,#3476fe);
	}
	.login-style-text{
		text-align: center;
		margin-top: 48rpx;
		font-size: 28rpx;
		color: #a6a6a6;
	}
}
.agreement{
	font-size: 24rpx;
	width: 490rpx;
	margin: 0 auto;
	margin-bottom: 40rpx;
	checkbox{
		transform:scale(0.5);
		vertical-align: middle;
		border-radius: 4rpx;
	}
	text{
		vertical-align: middle;
	}
}
.bluetext{
	color: #3476fe !important;
}
.code{
	button{
		border: none;
		background-color: #3476fe;
		color: white;
	}
}
</style>
